

import java.util.ArrayList;
import java.util.List;


import weka.classifiers.neural.lvq.model.CodebookVector;
import weka.classifiers.neural.lvq.model.CommonModel;
import weka.core.Instance;


public class MySom extends Som{
	public CommonModel getModel(){
		return model;
	}
	public CodebookVector[] getCodeBook(){
		return model.getCodebookVectors();
	}
	
	public ArrayList<CodebookVector> getBmus(int count){
		CodebookVector[] codebookCollection = getCodeBook();
		ArrayList<CodebookVector> bmus;
		int hitCounts[][] = new int[codebookCollection.length][2];
		
		for (int i = 0; i < codebookCollection.length; i++)
		{
			hitCounts[i][0] = codebookCollection[i].getBmuCorrectCount() + codebookCollection[i].getBmuIncorrectCount();
			hitCounts[i][1] = i;
		}
		
		QuickSort sort = new QuickSort();
	//	for(int[] s : hitCounts) System.out.print(s[1] + " " + s[0] + "\n");
		sort.sort(hitCounts);
	//	for(int[] s : hitCounts) System.out.print(s[1] + " " + s[0] + "\n");
		bmus = new ArrayList<CodebookVector>();
		for(int i = 0; i<count; i++){
			bmus.add(codebookCollection[codebookCollection.length - i - 1]);
		}
	    return bmus;
	}
	
	public CodebookVector getBmuForInstance(Instance instance){
		return model.getBmu(instance);
	}
}
